/* mousestroke theme related script */

$(document).ready(function() {

	/* Views */
	/* submit exposed filter form on control value change */
	$('.views-exposed-form .views-exposed-widget select.form-select').change(function(e) {
		try { e.target.form.submit(); }
		catch (ex) {}
	});

	/* Syntax highlight */
	$('.syntax-highlight').each(function() {
		var el = this, code = el.innerHTML, jel = $(el), fin = null, t;

		if (/^code$/i.test(el.nodeName)) {
			jel.html('<span>' + code + '</span>');
		} else if (/^pre$/i.test(el.nodeName)) {
			t = 0;
			jel = $('<ol></ol>').html(code.replace(/([^\n]*)\n?/g, function(s, l) {
				return '<li class="' + (++t % 2 ? 'odd' : 'even') + '">' + l + '</li>';
			}));
			el = jel[0];
			t = $(this);
			fin = function() { t.after(el).hide(); }
		} else return;

		jel.addClass(this.className + ' source-view');

		new JavaScriptSourceSyntaxHighlighter(el, null, null, fin).process();
	});
});
